package logic

import (
	"context"
	"product666/userrpc/userrpc"

	"product666/api/internal/svc"
	"product666/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type LikelistLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewLikelistLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LikelistLogic {
	return &LikelistLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *LikelistLogic) Likelist(req *types.LikelistRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	likelist, err := l.svcCtx.UserRpc.Likelist(l.ctx, &userrpc.LikelistRequest{})
	if err != nil {
		return &types.Response{
			Message:  err.Error(),
			Code:     "500",
			Database: nil,
		}, nil
	}
	return &types.Response{
		Message:  "收藏排行榜展示成功",
		Code:     "200",
		Database: likelist,
	}, nil
}
